const defaultState = {
  inputValue: '请输入用户名',
  list: []
}

export default (state = defaultState, action) => {
  if (action.type === 'change_input') {
    const newState = JSON.parse(JSON.stringify(state))
    newState.inputValue = action.value
    return newState
  }

  if (action.type === 'add_item') {
    const newState = JSON.parse(JSON.stringify(state))
    newState.list = newState.list.concat(newState.inputValue)
    return newState
  }

  return state
}
